<template>
  <div class="app-container">
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="checkQuery.name" placeholder="学生名" />
      </el-form-item>

      <el-form-item>
        <el-input v-model="checkQuery.studentNumber" placeholder="学号" />
      </el-form-item>

      <el-form-item >
        <el-input v-model="checkQuery.batch" placeholder="批次" />
      </el-form-item>

      <el-form-item >
        <el-select v-model="checkQuery.clazz" filterable  placeholder="请选择班级" style="width: 160px;">
          <div v-for="(item, index) in clazzList" :key="index">
            <el-option :label="item" :value="item"></el-option>
          </div>
        </el-select>
      </el-form-item>

      <!-- <el-form-item label="学院">
        <el-select v-model="checkQuery.academyId" placeholder="请选择学院" style="width: 200px;">
          <div v-for="(item, index) in academyList" :key="index">
            <el-option :label="item.name" :value="item.id"></el-option>
          </div>
        </el-select>
      </el-form-item>
      <el-form-item label="专业">
        <el-select v-model="studentQuery.majorId" placeholder="请选择专业" style="width: 200px;">
          <div v-for="(item, index) in majorList" :key="index">
            <el-option :label="item.name" :value="item.id"></el-option>
          </div>
        </el-select>
      </el-form-item>


      <el-form-item label="状态">
        <el-select style="width: 100px;" v-model="studentQuery.disabled" placeholder="状态">
          <el-option label="启用" :value="0"></el-option>
          <el-option label="禁用" :value="1"></el-option>
        </el-select>
      </el-form-item> -->

      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>
    <!-- 表格 -->
    <el-table :data="list" element-loading-text="数据加载中" border fit highlight-current-row>

      <el-table-column label="序号" width="70" align="center">
        <template slot-scope="scope">
          <!-- 获取序号的一种算法 -->
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="name" label="姓名" width="80" align="center" />

      <el-table-column prop="studentNumber" label="学号" width="140" align="center" />

      <el-table-column prop="institute" label="学院" width="160" align="center" />

      <el-table-column prop="clazz" label="班级" width="200" align="center" />

      <el-table-column prop="batch" label="批次" width="160" align="center" />

      <el-table-column prop="gmtCreate" label="签到时间" width="170" align="center" />


      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="updateCheck(scope.row)">修改</el-button>
          <el-button type="danger" size="mini" @click="deleteCheck(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table> 
    
    <!-- 分页 -->
    <el-pagination :current-page="page" :page-size="limit" :total="total" style="padding: 30px 0; text-align: center;" layout="total, prev, pager, next, jumper" @current-change="getList" />

  </div>
</template>

<script>
import checkInData from '@/api/checkInData/checkInData'
export default {

  data() {
    // 定义变量和初始值
    return {
      checkQuery:{},
      list:[],
      total: 0, // 总记录数
      page: 1, // 当前页
      limit: 10, // 每页记录数
      clazzList:[
        "计算机2101",
        "计算机2102",
        "计算机2103",
        "计算机2104",
        "计创本2101",
        "计师本2101",
        "智能本2101",
        "通信本2101",
        "通信本2102"
      ]
    }
  },
  created() {
    // 页面渲染之前执行，一般调用methods定义的方法
    // 调用
   this.getList()
  },
  methods: {
    getList(page = 1){
      this.page=page
      checkInData.getPageList(this.page,this.limit,this.checkQuery)
      .then((res)=>{
        console.log(res)
        this.list=res.data.items
        console.log(this.list)
        this.total=res.data.total
        this.$message({
          type: 'success',
          message: '查询成功',
        })
      })
    },
    resetData(){
      this.checkQuery={}
      this.getList()
    },
      updateCheck(){
        this.$notify({
          title: '提示',
          message: '暂时不可以修改哦',
          type:'info'
        });
      },
      deleteCheck(){
            this.$notify({
              title: '权限提示',
              message: '你没有删除的权限哦',
              type:"error"
            });
      }
  },


}
</script>